Código fuente de 'Filtro de palabras.asp'

<html>

<head>
<title>Filtro de palabras - Códigos asp, programacion asp, descargas asp, rutinas asp</title>
</head>

<body style="font-family: Arial; font-size: 9pt">

<center><b><font size="3" face="Arial">Filtro de palabras</font></b></center>
<br>
<%
Dim sComments
sComments = ReemplazaTacos(Request.Form("txtComments"))
response.write sComments

Function ReemplazaTacos(InputComments) 
Dim badChars, newChars, i
'create our array of bad words
badChars = array("idiota", "imbécil", "cabrón", "mierda")
newChars = InputComments
for i = 0 to uBound(badChars) 
newChars = Replace(newChars, badChars(i), "") 
Next 
ReemplazaTacos = newChars 
End function 
%> Aquí tenéis dos funciones:<br>
- Una reemplaza las palabras malsonantes, quitándolas.<br>
- Y la otra lo que hace es escribir sólo la primera letra y las demás las sustituye 
por &quot;*&quot;.<br>
Para que funcione, crea un array con las palabras malsonantes.<br>
<br>
Ejemplo: &quot;Eres un maldito cabrón de mierda&quot; <%
Dim Frase
Frase1="Frase: Eres un maldito cabrón de mierda<br>"
Frase2 = ReemplazaTacos("Eres un maldito cabrón de mierda")
response.write "<br><br>"&Frase1 & "Aplicando la función 1 --> " & frase2
Frase3 = ReemplazaTacos2("Eres un maldito cabrón de mierda")
response.write "<br>"&Frase1 & "Aplicando la función 2 --> " & frase3



Function ReemplazaTacos2(InputComments)

Dim badChars, newChars, sLength, sAttachtoEnd, x, i
'create an array of bad words that should be filtered
badChars = array("idiota", "imbécil", "cabrón", "mierda")
newChars = InputComments

'loop through our array of bad words
For i = 0 to uBound(badChars)
'get the length of the bad word
sLength=Len(badChars(i))
'we are going to keep the first letter of the bad word and replace all the other 
'letters with *, so we need to find out how many * to use
For x=1 to sLength-1
sAttachtoEnd=sAttachtoEnd & "*"
Next
'replace any occurences of the bad word with the first letter of it and the 
'rest of the letters replace with *
newChars = Replace(newChars, badChars(i), Left(badChars(i),1) & sAttachtoEnd)
sAttachtoEnd=""
Next
ReemplazaTacos2 = newChars

End function
%>

</body></html>